{extend name="/base"}

{block name="header"}
    <h2>添加角色</h2>
{/block}

{block name="body"}
    <form class="layui-form">
        {include file="role/_form" /}
    </form>
{/block}

{block name="js"}
<script>
    layui.use(['jquery','table','element','form','layer'],function () {
        var table=layui.table;
        var $=layui.jquery;
        var element=layui.element;
        var form=layui.form;
        var layer=layui.layer;

        form.on('submit(formDemo)',function (data) {
            var load = layer.load();
            $.post("{:url()}",data.field,function (res) {
                layer.close(load);
                if (res.code==1){
                    layer.msg(res.msg,{icon:1,time:1500},function () {
                        if (res.url) location.href = res.url;
                    })
                } else {
                    layer.msg(res.msg,{icon:2,time:1500})
                }
            });
            return false
        })

    })
</script>
{/block}